package com.chuangjiangx.member.stored.ddd.domain.model;

import com.chuangjiangx.domain.shared.model.PayEntry;
import com.chuangjiangx.domain.shared.model.PayTerminal;
import com.chuangjiangx.domain.shared.model.PayType;
import lombok.Getter;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author cj-ch
 * @date 2018/6/6 下午6:40
 * 交易成功后回调会员系统
 */
@ToString
@Getter
public class TradeCallBackMbr {
    private Long orderId;
    private String orderNumber;
    private BigDecimal amount;
    private BigDecimal discountAmount;
    private BigDecimal realPayAmount;
    private PayEntry payEntry;
    private PayType payType;
    private PayTerminal payTerminal;
    private Integer payChannel;
    private Date payTime;

    private Type type;

    // 当前退款金额
    private BigDecimal refundAmount;
    // 已退款金额
    private BigDecimal refundedAmount;
    private String refundNumber;

    private Long merchantId;
    private Long merchantUserId;
    private Long memberId;

    private TradeCallBackMbr(){}
    public enum Type{
        PAY,
        REFUND;
    }

    public static class Build{
        private Long orderId;
        private String orderNumber;
        private BigDecimal amount;
        private BigDecimal discountAmount;
        private BigDecimal realPayAmount;
        private PayEntry payEntry;
        private PayType payType;
        private PayTerminal payTerminal;
        private Integer payChannel;
        private Date payTime;
        private Type type;

        private BigDecimal refundAmount;
        private BigDecimal refundedAmount;
        private String refundNumber;

        private Long merchantId;
        private Long merchantUserId;
        private Long memberId;

        public TradeCallBackMbr build(){
            TradeCallBackMbr m = new TradeCallBackMbr();
            m.orderId = this.orderId;
            m.orderNumber = this.orderNumber;
            m.amount = this.amount;
            m.discountAmount = this.discountAmount;
            m.realPayAmount = this.realPayAmount;
            m.payEntry = this.payEntry;
            m.payType = this.payType;
            m.payTerminal = this.payTerminal;
            m.payChannel = this.payChannel;
            m.payTime = this.payTime;
            m.type = this.type;
            m.refundAmount = this.refundAmount;
            m.refundedAmount = this.refundedAmount;
            m.refundNumber = this.refundNumber;
            m.merchantId = this.merchantId;
            m.merchantUserId = this.merchantUserId;
            m.memberId = this.memberId;

            return m;
        }

        public Build setOrderId(Long orderId) {
            this.orderId = orderId;
            return this;
        }

        public Build setOrderNumber(String orderNumber) {
            this.orderNumber = orderNumber;
            return this;
        }

        public Build setAmount(BigDecimal amount) {
            this.amount = amount;
        	return this;
		}

        public Build setDiscountAmount(BigDecimal discountAmount) {
            this.discountAmount = discountAmount;
        	return this;
		}

        public Build setRealPayAmount(BigDecimal realPayAmount) {
            this.realPayAmount = realPayAmount;
        	return this;
		}

        public Build setPayEntry(PayEntry payEntry) {
            this.payEntry = payEntry;
        	return this;
		}

        public Build setPayType(PayType payType) {
            this.payType = payType;
        	return this;
		}

        public Build setPayTerminal(PayTerminal payTerminal) {
            this.payTerminal = payTerminal;
            return this;
        }

        public Build setPayChannel(Integer payChannel) {
            this.payChannel = payChannel;
            return this;
        }

        public Build setPayTime(Date payTime) {
            this.payTime = payTime;
        	return this;
		}

        public Build setType(Type type) {
            this.type = type;
            return this;
        }

        public Build setRefundAmount(BigDecimal refundAmount) {
            this.refundAmount = refundAmount;
            return this;
        }

        public Build setRefundNumber(String refundNumber) {
            this.refundNumber = refundNumber;
            return this;
        }

        public Build setMerchantId(Long merchantId) {
            this.merchantId = merchantId;
            return this;
        }

        public Build setMerchantUserId(Long merchantUserId) {
            this.merchantUserId = merchantUserId;
            return this;
        }

        public Build setRefundedAmount(BigDecimal refundedAmount) {
            this.refundedAmount = refundedAmount;
            return this;
        }

        public Build setMemberId(Long memberId) {
            this.memberId = memberId;
            return this;
        }
    }
}
